package com.wcl.demo.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by dllo on 15/11/27.
 */
public class TimeStampUtils {
    private static TimeStampUtils timeStampUtils;
    public static TimeStampUtils getInstance(){
        if(timeStampUtils==null){
            timeStampUtils=new TimeStampUtils();
        }
        return timeStampUtils;
    }
    public static String stampToDate(Long timestamp){
        String date = new java.text.SimpleDateFormat("MM月dd日 HH:mm").format(new java.util.Date(timestamp));
        return date;
    }
    public static String stampToDate(String timestampString){
        Long timestamp = Long.parseLong(timestampString);
        String date = new java.text.SimpleDateFormat("MM月dd日 HH:mm").format(new java.util.Date(timestamp));
        return date;
    }
    public static String stampToDate2(Long timestamp){
        String date = new java.text.SimpleDateFormat(" HH:mm").format(new java.util.Date(timestamp));
        return date;
    }
    public static String stampToDate2(String timestampString){
        Long timestamp = Long.parseLong(timestampString);
        String date = new java.text.SimpleDateFormat(" HH:mm").format(new java.util.Date(timestamp));
        return date;
    }
    public static long getTimesmorning(){
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return (cal.getTimeInMillis()/1000);
    }

}
